<div class="header-btns row">
    <button class="btn btn-success pull-right" ng-click="new()">New</button>
</div>

<div class="row" style="overflow-x: hidden">
    <div id="main-panel" class="cf-container col-md-8" dnd-list="customFields"
         dnd-effect-allowed="all"
         dnd-inserted="insertCallback()">

        <div class="alert alert-info" style="text-align: center" ng-if="customFields.length === 0">There isn't any
            custom field created
        </div>

        <div class="row cf-item" ng-repeat="cf in customFields | orderBy:'field_order'"
             dnd-draggable="cf"
             dnd-moved="customFields.splice($index, 1)"
             ng-class="{'selected': models.selected === item}">
            <div class="col-md-10">
                <h3 class="cf-display-name"> {{cf.field_display_name}}</h3>
                <div class="cf-name"> {{cf.field_name}}</div>
                <div class="cf-type type-int" ng-if="cf.field_type == 'int'">INTEGER</div>
                <div class="cf-type type-list" ng-if="cf.field_type == 'list'">LIST</div>
                <div class="cf-type type-str" ng-if="cf.field_type == 'str'">STRING</div>
            </div>
            <div class="cf-actions col-md-2">
                <span class="cf-icon-action" ng-click="_delete(cf)"><i
                        class="fa fa-trash-o fa-2x"></i></span>
                <span class="cf-icon-action" ng-click="setCustomField(cf)"><i class="fa fa-pencil fa-2x"></i></span>
                <span class="cf-icon-action handle-move" style="cursor: move"><i
                        class="fa fa-arrows-alt fa-2x"
                        title="You can drag and drop each custom field to reorder"></i></span>
            </div>
        </div>
    </div>

    <div id="slide" class="col-md-4 cf-detail">
        <h3><span ng-if="isEditable == true">Edit</span>
            <span ng-if="isEditable == false">Create</span>
            custom field
        </h3><br>
        <form name="form" role="form">
            <div class="tab-pane-header">Display Name</div>
            <div class="form-group">
                <label class="sr-only control-label" for="cf_display_name">Display Name</label>
                <input type="text" class="form-control" id="cf_display_name" placeholder="Display Name"
                       ng-model="selected_cf.field_display_name" required/>
            </div><!-- .form-group -->

            <div class="tab-pane-header">Name</div>
            <div class="form-group">
                <label class="sr-only control-label" for="cf_name">Name</label>
                <input type="text" class="form-control" id="cf_name" placeholder="Name" ng-readonly="isEditable == true"
                       ng-model="selected_cf.field_name" ng-change="normalizeName()" required/>
            </div><!-- .form-group -->

            <div class="row" style="margin-top: 32px;">
                <div class="btn-group col-md-6">
                    <div class="tab-pane-header">Type</div>
                    <button type="button" class="dropdown-toggle btn-change-property primary-btn"
                            data-toggle="dropdown"
                            id="btn-chg-type">
                        <span ng-if="selected_cf.field_type == null">UNDEFINED</span>
                        <span ng-if="selected_cf.field_type == 'int'">INTEGER</span>
                        <span ng-if="selected_cf.field_type == 'list'">LIST</span>
                        <span ng-if="selected_cf.field_type == 'str'">STRING</span>
                    </button>
                    <button type="button" class="dropdown-toggle secondary-btn btn-change-property"
                            data-toggle="dropdown"
                            id="caret-chg-type"
                            title="Change type">
                        <span> <i class="fa fa-angle-down fa-lg" aria-hidden="true"></i> </span>
                    </button>
                    <ul class="dropdown-menu dropdown-menu-right" role="menu">
                        <li>
                            <a class="ws"
                               ng-click="changeType(null)">UNDEFINED</a>
                            <a class="ws"
                               ng-click="changeType('str')">STRING</a>
                            <a class="ws"
                               ng-click="changeType('int')">INTEGER</a>
                            <a class="ws"
                               ng-click="changeType('list')">LIST</a>
                        </li>
                    </ul>
                </div>


                <!--<div class="col-md-6">-->
                <!--<div class="tab-pane-header">Order</div>-->
                <!--<div class="form-group">-->
                <!--<label class="sr-only control-label" for="cf_order">Order</label>-->
                <!--<input type="text" class="form-control" id="cf_order" placeholder="Order"-->
                <!--ng-model="selected_cf.field_order" check-custom-type="int" title="Type only numbers"/>-->
                <!--</div>&lt;!&ndash; .form-group &ndash;&gt;-->
                <!--</div>-->
            </div>

            <div class="btn-tools">
                <button type="reset" class="btn btn-default" ng-click="hideSidePanel()">Cancel</button>
                <button class="btn btn-success" ng-if="isEditable == true"
                        ng-click="updateCustomCustomField()"
                        ng-disabled="form.$invalid || selected_cf.field_type == null">Edit
                </button>
                <button class="btn btn-success" ng-if="isEditable == false"
                        ng-click="createCustomCustomField()"
                        ng-disabled="form.$invalid || selected_cf.field_type == null">Save
                </button>
            </div>
        </form>
    </div>
</div>
